package com.test.server.handler;

import com.test.coder.Decoder;
import com.test.coder.Encoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.timeout.IdleStateHandler;

public class ServerHandlerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline().addLast(new IdleStateHandler(5, 0, 0));
        ch.pipeline().addLast(new ServerIdleStateTrigger());
        ch.pipeline().addLast(new LoggingHandler(LogLevel.DEBUG));
        ch.pipeline().addLast(new Encoder());
        ch.pipeline().addLast(new Decoder());
        ch.pipeline().addLast(new TcpServerHandler());
    }
}
